class CapMailer < ActionMailer::Base
  
  @@sender_address = %("Capistrano Deployment" <capistrano@default.com>)
  cattr_accessor :sender_address

  @@recipient_addresses = []
  cattr_accessor :recipient_addresses

  @@email_prefix = "[DEPLOYMENT]-[#{ENV['RAILS_ENV']}]"
  cattr_accessor :email_prefix

  @@site_name = ""
  cattr_accessor :site_name

  @@email_content_type = "text/html"
  cattr_accessor :email_content_type

  def self.reloadable?; false; end

  def notification_email(rails_env, repository, command, deploy_to, host = nil, ip_address = nil, output = nil, data = {})
    subject    "#{email_prefix}[#{rails_env}][#{repository}] "

    recipients recipient_addresses
    from       sender_address
    
    content_type email_content_type

    body       data.merge({ 
                :command => command,
                :output => output,
                :host => host,
                :ip_address => ip_address,
                :date => Date.today.to_s,
                :time => Time.now.strftime("%I:%M %p"),
                :site_name => self.site_name,
                :deploy_to => deploy_to,
                :rails_env => rails_env
               })
  end

end
